package collection;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;

/**
 * @author DBX
 * @effect 改错题
 *          程序需求:向一个List集合中添加10个数字1-10，并将它们
 *          遍历出来并输出到控制台。
 * @date 2021/09/04/16:02
 */
public class Test1 {
    public static void main(String[] args) {
		List<Integer> list = new ArrayList<>();
        Random random = new Random();
        for (int i = 0; i < 10; i++) {
            list.add(random.nextInt(10));
        }
        System.out.println(list);
        for (Integer integer : list) {
            System.out.print(integer+" ");
        }
        System.out.println();
        Iterator it = list.iterator();
        while(it.hasNext()) {
            System.out.print(it.next()+" ");
        }
    }
}
